#pragma once
#include<iostream>
#include<string>
#include <unistd.h>
#include<vector>
#include<unordered_map>
#include<functional>

typedef std::function<void()> func;

std::vector<func> callbacks;
std::unordered_map<int,std::string> desc;

void task_MySQl()
{
    std::cout<< "process[" << getpid()<<"]"<<"执行MySQL任务"<<std::endl;
}

void task_URL()
{
    std::cout<< "process[" << getpid()<<"]"<<"执行URL任务"<<std::endl;
}

void task_CAL()
{
    std::cout<< "process[" << getpid()<<"]"<<"执行CAL任务"<<std::endl;
}

void task_SAVE()
{
    std::cout<< "process[" << getpid()<<"]"<<"执行SAVE任务"<<std::endl;
}

void load()
{
    desc.insert({callbacks.size(),"task_MySQl"});
    callbacks.push_back(task_MySQl);

    desc.insert({callbacks.size(),"task_URL"});
    callbacks.push_back(task_URL);

    desc.insert({callbacks.size(),"task_CAL"});
    callbacks.push_back(task_CAL);

    desc.insert({callbacks.size(),"task_SAVE"});
    callbacks.push_back(task_SAVE);

}

void showHandler()
{
    for(auto& iter : desc)
    {
        std::cout<< iter.first<<"\t"<<iter.second<<std::endl;
    }
}

int TaskSize()
{
    return callbacks.size();
}